import paramiko


def SshComm(ip, port, user, password, Commonds, Test=0):
    if Test:
        print(Commonds)
    ssh = paramiko.SSHClient()
    ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
    ssh.connect(ip, port, user, password, timeout=10)
    # Commond 是一个tuple
    result = {}
    for Commond in Commonds:
        stdin, stdout, stderr = ssh.exec_command(Commond)
        result[Commond] = {"stdout": stdout.read().decode(), "stderr": stderr.read().decode()}
    ssh.close()
    return result
